package com.cnkvha.trackcontestmgmt.ui;

import com.cnkvha.trackcontestmgmt.ContestDataManager;
import com.cnkvha.trackcontestmgmt.contest.Contest;

import javax.swing.*;

public class ContestListModel extends DefaultListModel<Contest> {

    private final ContestDataManager cdm;

    public ContestListModel(ContestDataManager cdm) {
        this.cdm = cdm;
    }

    @Override
    public int getSize() {
        if(cdm == null) return 0;
        return cdm.getContestCount();
    }

    @Override
    public Contest getElementAt(int index) {
        return cdm.getAt(index);
    }

    @Override
    public Contest get(int index) {
        return cdm.getAt(index);
    }
}
